﻿<UserControl x:Class="FIFP.DashBoard.Views.UCAppointment_New"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:converter="clr-namespace:FIFP.DashBoard.Converters"
    xmlns:vm="clr-namespace:FIFP.DashBoard.ViewModel"
    DataContext="{Binding AppointmentVM,Source={StaticResource ServiceLocator}}"
    xmlns:Presentation="clr-namespace:FIFP.Common.Behaviors.CommonEventArgs;assembly=FIFP.Common"
    mc:Ignorable="d">


    <UserControl.Resources>
        <!--<converter:ViewDefinitionToBooleanConverter x:Key="ViewDefinitionToBooleanConverter" />-->
        <DataTemplate x:Key="AppointmentToolTipTemplate">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <TextBlock Text="Division: "/>
                <TextBlock Text="{Binding Path=Appointment.Division}" Grid.Column="1"/>
                <TextBlock Grid.Row="1" Text="UnitName: "/>
                <TextBlock Grid.Row="1" Text="{Binding Path=Appointment.UnitName}" Grid.Column="1"/>
                <TextBlock Grid.Row="2" Text="UnitType: "/>
                <TextBlock Grid.Row="2" Text="{Binding Path=Appointment.UnitType}" Grid.Column="1"/>
                <TextBlock Grid.Row="3" Text="UnitStatus: "/>
                <TextBlock Grid.Row="3" Text="{Binding Path=Appointment.UnitStatus}" Grid.Column="1"/>
                <TextBlock Grid.Row="4" Text="FluidType: "/>
                <TextBlock Grid.Row="4" Text="{Binding Path=Appointment.FluidType}" Grid.Column="1"/>
                <TextBlock Grid.Row="5" Text="Modified Start: "/>
                <TextBlock Grid.Row="5" Text="{Binding Path=Appointment.Start,StringFormat='M/dd/yyyy'}" Grid.Column="1"/>
                <TextBlock Grid.Row="6" Text="Modified End: "/>
                <TextBlock Grid.Row="6" Text="{Binding Path=Appointment.End,StringFormat='M/dd/yyyy'}" Grid.Column="1"/>
            </Grid>

        </DataTemplate>

        <SolidColorBrush x:Key="GroupHeaderForeground" Color="#B2020202" />

        <!--<converter:OrientedGroupHeaderContentTemplateSelector x:Key="GroupHeaderContentTemplateSelector">            
            <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=%d MMM}"/>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalMonthViewDateTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}"/>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalDayViewDateTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalWeekViewDateTemplate>
                <DataTemplate>
                    <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}"/>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalWeekViewDateTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
                <DataTemplate>
                    <TextBlock Foreground="{StaticResource GroupHeaderForeground}" FontSize="16" Margin="0" Text="{Binding Name.DisplayName}" />
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.HorizontalResourceTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.VerticalWeekViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.VerticalWeekViewDateTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.VerticalDayViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=dd dddd}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.VerticalDayViewDateTemplate>

            <converter:OrientedGroupHeaderContentTemplateSelector.VerticalMonthViewDateTemplate>
                <DataTemplate>
                    <telerik:LayoutTransformControl>
                        <telerik:LayoutTransformControl.LayoutTransform>
                            <RotateTransform Angle="-90" />
                        </telerik:LayoutTransformControl.LayoutTransform>
                        <TextBlock Margin="4" Text="{Binding Name, StringFormat=%d MMM}" VerticalAlignment="Top" />
                    </telerik:LayoutTransformControl>
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.VerticalMonthViewDateTemplate>
            <converter:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
                <DataTemplate>
                    <TextBlock Foreground="{StaticResource GroupHeaderForeground}" Margin="-2 3 0 5" FontSize="16" Text="{Binding Name.DisplayName}" />
                </DataTemplate>
            </converter:OrientedGroupHeaderContentTemplateSelector.VerticalResourceTemplate>
        </converter:OrientedGroupHeaderContentTemplateSelector>-->

        <Style x:Key="HorizontalBottomLevelGroupHeaderStyle" TargetType="telerik:GroupHeader" BasedOn="{StaticResource GroupHeaderBaseStyle}">
            <Setter Property="Margin" Value="0 0 -1 0" />
            <Setter Property="Padding" Value="0 0 5 0" />
            <Setter Property="Canvas.ZIndex" Value="-2" />
            <Setter Property="Foreground" Value="Red"/>
            <Setter Property="FontStyle" Value="Italic"/>
        </Style>

    </UserControl.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <StackPanel Orientation="Horizontal" Grid.Row="0" HorizontalAlignment="Left" Margin="0,0,0,10">
            <TextBlock Text="Zoom: " Style="{StaticResource SmallHeading}" VerticalAlignment="Center" Margin="0,0,10,0" />
            <telerik:RadSlider Width="150" Minimum="{Binding ActualHeight, ElementName=radView}" Maximum="4000" Margin="0" Style="{StaticResource RadSliderStyle1}"
						VerticalAlignment="Center" Value="{Binding ActiveViewDefinition.MinTimeRulerExtent, ElementName=radView, Mode=TwoWay}" LargeChange="50" />

        </StackPanel>

        <telerik:RadScheduleView ToolTipTemplate="{StaticResource AppointmentToolTipTemplate}" Grid.Row="1" x:Name="radView" ActiveViewDefinitionIndex="3"
                                 AppointmentsSource="{Binding FilteredAppointments}" GroupHeaderStyleSelector="{StaticResource GroupHeaderStyleSelector}" ResourceTypesSource="{Binding ResourceTypes}" 
                                 EditAppointmentDialogStyle="{StaticResource EditAppointmentDialogStyle}" DragDropBehavior="{Binding RadScheduleViewDragDropBehavior}" 
                                 NavigationHeaderVisibility="{Binding NavigationVisibility}" CurrentDate="{Binding CurrentDate}" Background="#FF353c48" BorderBrush="#FF353c48">


            <i:Interaction.Triggers>


                <i:EventTrigger EventName="AppointmentCreating">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentCreateCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />

                </i:EventTrigger>

                <i:EventTrigger EventName="ShowDialog">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.DialogCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />

                </i:EventTrigger>

                <i:EventTrigger EventName="Loaded">
                    <i:InvokeCommandAction Command="{Binding GroupTypeResourceLoadCommand}" 
        							CommandParameter="{Binding ElementName=radView}" />
                </i:EventTrigger>
                
                <i:EventTrigger EventName="AppointmentEditing">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentEditingCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                </i:EventTrigger>

                <i:EventTrigger EventName="AppointmentEdited">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentEditCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                </i:EventTrigger>

                <i:EventTrigger EventName="AppointmentDeleting">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentDeletingCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                </i:EventTrigger>
                
                <i:EventTrigger EventName="AppointmentDeleted">
                    <Presentation:InvokeDelegateCommandAction
                                Command="{Binding Source={StaticResource ServiceLocator},Path=AppointmentVM.AppointmentDeleteCommand}"
                                CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=InvokeParameter}" />
                </i:EventTrigger>

               

            </i:Interaction.Triggers>

            <telerik:RadScheduleView.ViewDefinitions>
                <!--<telerik:DayViewDefinition MinTimeRulerExtent="1" MinorTickLength="{Binding MajorTickLength}" MajorTickLength="{Binding MajorTickLength}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:DayViewDefinition>
                <telerik:WeekViewDefinition MinTimeRulerExtent="1" MinorTickLength="{Binding MajorTickLength}" MajorTickLength="{Binding MajorTickLength}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:WeekViewDefinition>
                <telerik:MonthViewDefinition MinTimeRulerExtent="1" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
						VisibleDays="{Binding VisibleDays}" AppointmentFilter="{Binding FilterValue}">
                </telerik:MonthViewDefinition>-->
                <!--<telerik:TimelineViewDefinition  MinTimeRulerExtent="8000" MaxTimeRulerExtent="800" MinorTickLength="{Binding MajorTickLength}" 
                         MajorTickLength="{Binding MajorTickLength}" GroupTickLength="{Binding GroupTickLength}" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
                         TimerulerMajorTickStringFormat="{}{0:M/d}" TimerulerMinorTickStringFormat="{}{0:M/d}" 
						 VisibleDays="{Binding VisibleDays}" StretchAppointments="False" StretchGroupHeaders="False" ShowTimeRuler="True" >
                </telerik:TimelineViewDefinition>-->

                <telerik:TimelineViewDefinition MinorTickLength="{Binding MajorTickLength}"
                         MajorTickLength="{Binding MajorTickLength}" GroupTickLength="{Binding GroupTickLength}" MinTimeRulerExtent="2000" TimerulerGroupStringFormat="{}{0:MMM,yyyy}" 
						 VisibleDays="{Binding VisibleDays}" StretchAppointments="False" StretchGroupHeaders="False">
                </telerik:TimelineViewDefinition>

            </telerik:RadScheduleView.ViewDefinitions>


            <!--<telerik:RadScheduleView.GroupDescriptionsSource>
                <telerik:GroupDescriptionCollection>
                    <telerik:DateGroupDescription />
                    <telerik:ResourceGroupDescription ResourceType="Unit" ShowNullGroup="False" />
                </telerik:GroupDescriptionCollection>
            </telerik:RadScheduleView.GroupDescriptionsSource>-->
            
            <!--<telerik:RadScheduleView.DragDropBehavior>
                <converter:ScheduleDragDropBehavior />
            </telerik:RadScheduleView.DragDropBehavior>-->

            <telerik:RadScheduleView.GroupHeaderContentTemplate>
                <DataTemplate>
                    <TextBlock Name="txtGroup" Foreground="White" Text="{Binding FormattedName}" Margin="0,0,10,0" Width="150" VerticalAlignment="Center" HorizontalAlignment="Right" TextAlignment="Right">

                    </TextBlock>
                </DataTemplate>
            </telerik:RadScheduleView.GroupHeaderContentTemplate>


            <telerik:RadScheduleView.TimeRulerItemStyleSelector>
                <converter:GroupItemStyleSelector>
                    <converter:GroupItemStyleSelector.DefaultStyle>
                        <Style TargetType="Control">
                            <Setter Property="Width" Value="1" />
                            <Setter Property="Height" Value="0" />
                        </Style>
                    </converter:GroupItemStyleSelector.DefaultStyle>                    
                </converter:GroupItemStyleSelector>
            </telerik:RadScheduleView.TimeRulerItemStyleSelector>

        </telerik:RadScheduleView>

    </Grid>
</UserControl>
